/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fsktms.request;

import java.io.Serializable;
import java.util.HashMap;

/**
 *
 * @author salm
 */
public class RequestParameters extends HashMap<String, Serializable>
{
    public static String KEY_FUNCTION = "Function";
    public static String KEY_FAILURE_CODE = "Failure_code";
    public static String KEY_FAILURE_DESCRIPTION = "Failure_description";
    public static String KEY_RESULT = "Result";
    
    public static int VALUE_FAILURE_CODE_NOT_FOUND = 404;
    public static int VALUE_FAILURE_CODE_FORBIDEN = 403;
    public static int VALUE_FAILURE_CODE_SERVER_ERROR = 500;
    public static int VALUE_FAILURE_CODE_ERROR = 202;
    
    public static void setFailure(RequestParameters params, int code, String codeDesc)
    {
        params.setFailure(code, codeDesc);
    }
    
    public void setFailure(int code, String codeDesc)
    {
        this.put(KEY_FAILURE_CODE, code);
        this.put(KEY_FAILURE_DESCRIPTION, codeDesc);
    }
    
    public RequestParameters set(String key, Serializable value)
    {
        this.put(key, value);
        
        return this;
    }
    
    public String getString(String key)
    {
        return (String) this.get(key);
    }
    
    public int getInteger(String key)
    {
        return (Integer) this.get(key);
    }
    
    public boolean getBoolean(String key)
    {
        return (Boolean) this.get(key);
    }
}